/**
 * 
 */
package uk.ac.lkl.common.util;

import java.lang.IllegalArgumentException;

import junit.framework.TestCase;

/**
 * @author yish
 *
 */
public class ArgsTest extends TestCase {

	private static String[] params = {"eeney", "meeney", "miney", "mo"};
	private static String[] goodArgs = {"-eeney", "bekini", "-meeney", "salamini", "-mo"};
	private static String[] badArgs = {"-zukiny", "bekini", "-meeney", "-salamini", "mo"};

	/**
	 * Test method for {@link uk.ac.lkl.common.util.Args#Args(java.lang.String[], java.lang.String[])}.
	 */
	public final void testArgs() {
		Args args = new Args(goodArgs,params);
		try {
			 args = new Args(badArgs,params);
			 fail("expected exception "+args.get("zukini")+" "+args.get("meeney"));			 
		} catch (IllegalArgumentException e) {
			// good.
		}		
	}

	/**
	 * Test method for {@link java.util.HashMap#containsKey(java.lang.Object)}.
	 */
	public final void testContainsKey() {
		Args args = new Args(goodArgs,params);
		if (!args.containsKey("mo")) fail("mo not found");
		if (args.containsKey("miney")) fail("miney not expected");
	}

	/**
	 * Test method for {@link java.util.HashMap#get(java.lang.Object)}.
	 */
	public final void testGet() {
		Args args = new Args(goodArgs,params);
		if (!args.get("mo").equals("")) fail("get(mo) should return empty string, got "+args.get("mo"));
		if (!args.get("eeney").equals("bekini")) fail("expected bekini, got "+args.get("eeney"));
	}

}
